package com.hkyl.hospital.web.controller;

import com.hkyl.hospital.domain.ResultVo;
import com.hkyl.hospital.entity.CaseHistory;
import com.hkyl.hospital.service.CaseHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hyh
 * @date 2023/07/14 15:36:37
 */
@RestController
@RequestMapping("caseHistory")
public class CaseHistoryController {

    @Autowired
    private CaseHistoryService caseHistoryService;

    @PostMapping("save")
    public ResultVo save(@RequestBody CaseHistory caseHistory){
        Integer row = caseHistoryService.save(caseHistory);
        return row > 0 ? ResultVo.success("病例保存成功") : ResultVo.failure("病例保存失败");
    }

    @PostMapping("getCase")
    public ResultVo getOne(@RequestBody String registerNo){
        CaseHistory caseHistory = caseHistoryService.getOne(registerNo);
        return ResultVo.success(caseHistory);
    }
}
